package com.terrynoya.fight.data.parser.sff
{
	import com.terrynoya.fight.combat.PlayerConstants;
	import com.terrynoya.fight.io.FileSystem;
	import com.terrynoya.fight.io.KeyValuePair;
	import com.terrynoya.fight.io.TextFile;
	import com.terrynoya.fight.io.TextSection;

	public class CharacterPropertyParser
	{
		public function CharacterPropertyParser()
		{
		}
		
		public static function build(txt:String):PlayerConstants
		{
			var playerConst:PlayerConstants = new PlayerConstants();
			var file:TextFile = FileSystem.build(txt);
			for (var i:int = 0; i < file.sections.length; i++) 
			{
				var section:TextSection = file.sections[i];
				switch(section.title)
				{
					case "Size":
					{
						initSize(playerConst,section);
						break;
					}
				}
			}
			return playerConst;
		}
		
		private static function initSize(playerConst:PlayerConstants,section:TextSection):void
		{
			for (var i:int = 0; i < section.parsedLines.length; i++) 
			{
				var vo:KeyValuePair = section.parsedLines[i];
				switch(vo.key)
				{
					case "attack.dist":
					{
						playerConst.attackDistance = int(vo.value);
						break;
					}
					case "ground.back":
					{
						playerConst.groundBack = int(vo.value);
						break;
					}
					case "ground.front":
					{
						playerConst.groundFront = int(vo.value);
						break;
					}
				}
			}
		}
	}
}